﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.IO;

namespace Curchy.MetablogCMS.Controllers
{
    public class ImageResult : ActionResult
    {
        public ImageResult(byte[] imageStream, string contentType)
        {
            this.ImageStream = imageStream;
            this.ContentType = contentType;
        }

        public byte[] ImageStream { get; private set; }
        public string ContentType { get; private set; }

        public override void ExecuteResult(ControllerContext context)
        {
            HttpResponseBase response = context.HttpContext.Response;
            response.ContentType = this.ContentType;
            response.OutputStream.Write(ImageStream, 0, ImageStream.Length);
            response.End();
        }
    }
}